<template>
	<view class="work-container">
		<uni-section title="欢迎使用" type="line"></uni-section>
		<view class="swiper-item">
			<image :src="image" mode="aspectFill" :draggable="false" />
		</view>
		<!--vuetop-->

		<view class=" bg-white margin-bottom-sm padding-xs  response  flex flex-wrap justify-start  ">
			<view class=" padding-xs  response  flex flex-wrap justify-between  " style="align-items: center;">
				<text class="text-xl text-bold "> 今天</text>
			</view>

			<view class=" padding-xs  response  flex flex-wrap justify-between  ">
				<view class=" padding-xs   flex flex-wrap justify-start  " style="align-items: center;">
					<text class=""> {{ IndexFillInfo.tagName }}</text>
				</view>
				<view class=" padding-xs   flex flex-wrap justify-start  " style="align-items: center;">
					<view class="" v-if="IndexFillInfo.fillStatus != 1">
						<view class=" cuIcon-edit " style="font-size: 46rpx;"></view>
						<text class="margin-right-sm " @click="handleCreate"> 提交</text>
					</view>
					<!-- <view v-if="IndexFillInfo.fillStatus == 1">
						<view class=" cuIcon-roundright " style="font-size: 46rpx;"></view>
						<text class="margin-right-sm " @click="handleShow"> 查看</text>
					</view> -->



				</view>
			</view>
		</view>
		<view class=" bg-white margin-bottom-sm padding-xs  response  flex flex-wrap justify-start  ">
			<view class=" padding-xs  response  flex flex-wrap justify-between  " style="align-items: center;">
				<text class="text-xl text-bold "> 本月</text>
				<!-- 	<text class="margin-right-sm "> 查看</text> -->
			</view>
			<view class="flex22  padding-xs  response    justify-start  ">
				<text class="flex flex-direction">已提交{{ IndexFillInfo.monthFill }}次</text>
				<text class="flex flex-direction ">缺勤{{ IndexFillInfo.monthMissFill }}次</text>
				<text class="flex flex-direction">请假{{ IndexFillInfo.leaveNum }}次</text>
				<text class="flex flex-direction ">倒休{{ IndexFillInfo.offDutyNum }}次</text>
			</view>
		</view>


		<view class=" bg-white margin-bottom-sm padding-xs  response  flex flex-wrap justify-start  ">
			<view class=" padding-xs  response  flex flex-wrap justify-between  " style="align-items: center;">
				<text class="text-xl text-bold "> 加入的项目</text>
				<text class="margin-right-sm " @click="handleProject"> 查看</text>
			</view>
			<view class="flex22  padding-xs  response    justify-start ">
				<text class=""> 已加入{{peojectcardInfo.length}} 个项目 </text>
			</view>
			<!-- <view class="flex22  padding-xs  response    justify-start  "  v-for="item in peojectcardInfo"
              :key="item.projectId">
			   <text class=""> 项目名称:  {{ item.projectCode }}    编码:  {{ item.projectCode }}   </text>
			</view> -->
		</view>

		<!--vuebottom-->
	</view>
</template>

<script>
		import moment from 'moment'
	import {
		getUserProfile
	} from "@/api/system/user";
	import {
		getIndexProjectStat,
		getIndexFillInfo,
		getIndexLoginUser
	} from "@/api/dashboard";
	export default {
		name: "index",
		data() {
			return {
				StatusBar: 0,
				// 版本号
				version: "3.6.0",
				usertime: "",
				username: "",
				cardStatus: true,
				queryParams: {
					pageNum: 1,
					pageSize: 5,
					roleName: undefined,
					roleKey: undefined,
					status: undefined
				},
				user: {},
				roleGroup: {},
				postGroup: {},
				peojectcardInfo: [],
				IndexFillInfo: {},
				IndexLoginUserInfo: [],
				workTime: null,
				image: '/static/images/banner/slider-1.png',

			};
		},
		onLoad() {
			this.getUser();
			this.init();
		},

		methods: {
			
			reload(){
				this.init();
			},
			getUser() {
				getUserProfile().then(response => {
					this.user = response.data;
					this.roleGroup = response.roleGroup;
					this.postGroup = response.postGroup;
					if (this.postGroup === "董事长") {
						this.username = this.postGroup;
					} else {
						this.username = this.user.nickName;
					}
					let datetime = Date().slice(16, 18);
					if (datetime < 13) {
						this.usertime = "上午好";
					} else {
						this.usertime = "下午好";
					}
				});
			},

			init() {
				getIndexProjectStat().then(res => {
					// console.log(res);
					if (res.code == 200) {
						this.peojectcardInfo = res.data;
						this.peojectcardInfo.forEach(el => {
							if (el.manHour < el.useHour) {
								el.cardStatus = false;
							} else {
								el.cardStatus = true;
							}
						});
						// console.log("peojectcardInfo", this.peojectcardInfo);
					}
				});
				getIndexFillInfo().then(res => {
					// console.log("getIndexFillInfo", res);
					if (res.code == 200) {
						this.IndexFillInfo = res.data;
						if (this.IndexFillInfo.fillStatus == 1) {
							this.IndexFillInfo.subtype = "danger";
							this.IndexFillInfo.tagName = "已上报";
						} else if (this.IndexFillInfo.fillStatus == 2) {
							this.IndexFillInfo.tagName = "未上报";
							this.IndexFillInfo.subtype = "success";
						} else if (this.IndexFillInfo.fillStatus == 3) {
							this.IndexFillInfo.tagName = "无需上报";
							this.IndexFillInfo.subtype = "";
						} else if (this.IndexFillInfo.fillStatus == 4) {
							this.IndexFillInfo.tagName = "节假日";
							this.IndexFillInfo.subtype = "";
						} else if (this.IndexFillInfo.fillStatus == 5) {
							this.IndexFillInfo.tagName = "请假";
							this.IndexFillInfo.subtype = "";
						} else if (this.IndexFillInfo.fillStatus == 6) {
							this.IndexFillInfo.tagName = "调休";
							this.IndexFillInfo.subtype = "";
						} else {
							this.IndexFillInfo.tagName = "未知状态，联系管理员";
							this.IndexFillInfo.subtype = "warning";
						}
					}
				});
				getIndexLoginUser(this.queryParams).then(res => {
					// console.log("getIndexLoginUser", res);
					if (res.code == 200) {
						this.IndexLoginUserInfo = res.rows;
						// console.log(" this.IndexLoginUserInfo", this.IndexLoginUserInfo);
					}
				});
			},

			handleCreate() {
				let hourDate = moment().format('YYYY-MM-DD')
				this.$tab.navigateTo('/pages/mhour/create?hourDate=' + hourDate)

			},
			handleShow() {
				let hourDate = moment().format('YYYY-MM-DD')
				this.$tab.navigateTo('/pages/mhour/show?hourDate=' + hourDate)
			},
			handleProject(){
				this.$tab.navigateTo('/pages/work/projectList')
			},
			submitWorkingHours() {
				// console.log("提交工时");
				this.$router.push({
					path: "/workingHours/myWorkingHours"
				});
			},
			checkWorkingHours() {
				// console.log("查看工时");
				// this.$router.push({ path: "/workingHours/myStatistics" });
				this.$router.push({
					path: "/workingHours/fillInWorkingHours"
				});
			},
			goTarget(href) {
				window.open(href, "_blank");
			}

		},




	}
</script>

<style>
	/**本页全局配置的代码**/
	.pageconfig {
		width: 100%;
		overflow: hidden;
		overflow-y: scroll;
		height: 100vh;
	}



	/**pagedomcss**/


	.toptitle2 {
		width: 100%;
		border-bottom: 2rpx solid rgba(106, 99, 99, 0.32);
	}

	.flex3 {
		width: 96%;
	}

	.text5 {
		font-weight: 700;
	}

	.flex9 {
		border-bottom: 2rpx solid rgba(230, 226, 226, 1);
	}

	.flex22 {
		border-bottom: 2rpx solid rgba(230, 226, 226, 1);
	}

	.swiper {
		height: 300rpx;
	}

	.swiper-box {
		height: 150px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #fff;
		height: 300rpx;
		line-height: 300rpx;
	}

	.text-wrap {
		overflow: hidden;
		-webkit-line-clamp: 1;
	}
</style>